<?php
session_start() ; 
include "functions.php" ; 
db() ; 
 
if(isset($_GET['start']))
{
$sql = mysql_num_rows(mysql_query('SELECT id FROM users where user="'.$_SESSION['user_info']['user'].'" and energy>=10'))  ; 

if($sql==1)
{
echo 1 ; 
mysql_query('UPDATE users set money=money+100,energy=energy-10 where user="'.$_SESSION['user_info']['user'].'"') ; 
}
else
{
echo "Нямаш енергия." ; 
}
}
else
{

$remain  = mysql_fetch_assoc(mysql_query('SELECT training FROM users WHERE user="'.$_SESSION['user_info']['user'].'"')) ; 

if($remain['training']==0)
{
echo 0 ; 
}
else
{

$izm = time()-$remain['training'] ;  
echo $izm ;  
}

}